package dmir.wikipedia.cleaners;


import java.util.regex.Pattern;



public class EnglishWikiPageCleaner extends AbstractWikiPageCleaner {


	public EnglishWikiPageCleaner(String title, StringBuilder rawText) {
		super(title, rawText);
	}

	protected Pattern getIgnoreTitlePattern()
	{
		return Pattern.compile(
				"(Lists_of_)|(List_of_)|(Index_of_)|(Table_of_)|(File:)|(Image:)|(Media:)|(Wikipedia:)|(Category:)|(Book:)" +
				"|(Special:)|(User:)|(Help:)|(Manual:)|(Template:)|(Wikt:)|(Wiktionary:)|(Wikinews:)|(Portal:)|(\\(disambiguation\\))",
				Pattern.CASE_INSENSITIVE);
	}

	@Override
	protected Pattern getDisambTemplatePattern() 
	{
		return Pattern.compile("\\{\\{disambig\\}\\}");
	}


	protected Pattern getDisambTitlePattern()
	{
		return Pattern.compile("(disambiguation)");
	}



	@Override
	protected Pattern getRedirectPattern() 
	{
		return Pattern.compile("#(REDIRECT)\\s*\\[\\[\\s*(.+)\\s*\\]\\]", Pattern.CASE_INSENSITIVE);
	}





	@Override
	protected Pattern getMediaLinksPattern() 
	{
		return Pattern.compile("(\\[\\[(File:|Image:)?)|(\\]\\])", Pattern.CASE_INSENSITIVE);
	}





	@Override
	protected Pattern getCategoryPattern() 
	{
		return Pattern.compile("Category:(.+)");
	}





	@Override
	protected Pattern getSpecialPattern() 
	{
		return Pattern.compile(
				"(((Lists_of_)|(List_of_)|(Table_of_)|(Media:)|(File:)|(Image:)|(Wikipedia:)|(Template:)|(Index_of_)" +
						"|(Special:)|(User:)|(Help:)|(Manual:)|(Wikt:)|(Wiktionary:)|(Wikinews:)|(Portal:)|(Book:)" +
						WIKIPEDIA_LANGUAGE_PREFIXES + ").+)" +
						"|(.*#.+)|(.+\\(disambiguation\\))\\s", Pattern.CASE_INSENSITIVE);
	}





	@Override
	public boolean isMediaLink(String text) 
	{
		return text.startsWith("[[File:") || text.startsWith("[[Image:");
	}
}
